Passed
Pull Request — master (#57)
by Salim
19:50
created

ToGenerator   A

Complexity

Conditions 5

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 1
c 0
b 0
f 0
dl 0
loc 1
rs 9.3333
1
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[17],{
2
3
/***/ 1007:
4
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5
6
"use strict";
7
__webpack_require__.r(__webpack_exports__);
8
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
9
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
10
/* harmony import */ var react_resize_detector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1004);
11
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(964);
12
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_2__);
13
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
0 ignored issues
show
Bug introduced by
The variable Symbol seems to be never declared. If this is a global, consider adding a /** global: Symbol */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
14
15
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
16
17
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
19
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
21
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
22
23
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
24
25
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
26
27
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
29
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
30
31
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
32
33
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
34
35
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
36
37
38
39
40
41
var DicomMicroscopyViewport =
42
/*#__PURE__*/
43
function (_Component) {
44
  _inherits(DicomMicroscopyViewport, _Component);
45
46
  function DicomMicroscopyViewport(props) {
47
    var _this;
48
49
    _classCallCheck(this, DicomMicroscopyViewport);
50
51
    _this = _possibleConstructorReturn(this, _getPrototypeOf(DicomMicroscopyViewport).call(this, props));
52
53
    _defineProperty(_assertThisInitialized(_this), "state", {
54
      error: null
55
    });
56
57
    _defineProperty(_assertThisInitialized(_this), "viewer", null);
58
59
    _defineProperty(_assertThisInitialized(_this), "onWindowResize", function () {
60
      _this.debouncedResize();
61
    });
62
63
    _this.container = react__WEBPACK_IMPORTED_MODULE_0___default.a.createRef();
64
    _this.debouncedResize = lodash_debounce__WEBPACK_IMPORTED_MODULE_2___default()(function () {
65
      if (_this.viewer) _this.viewer.resize();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
66
    }, 100);
67
    return _this;
68
  } // install the microscopy renderer into the web page.
69
  // you should only do this once.
70
71
72
  _createClass(DicomMicroscopyViewport, [{
73
    key: "installOpenLayersRenderer",
74
    value: function installOpenLayersRenderer(container, displaySet) {
75
      var _this2 = this;
76
77
      var dicomWebClient = displaySet.dicomWebClient;
78
      var searchInstanceOptions = {
79
        studyInstanceUID: displaySet.StudyInstanceUID,
80
        seriesInstanceUID: displaySet.SeriesInstanceUID
81
      };
82
      dicomWebClient.searchForInstances(searchInstanceOptions).then(function (instances) {
83
        var promises = [];
84
85
        for (var i = 0; i < instances.length; i++) {
86
          var sopInstanceUID = instances[i]['00080018']['Value'][0];
87
          var retrieveInstanceOptions = {
88
            studyInstanceUID: displaySet.StudyInstanceUID,
89
            seriesInstanceUID: displaySet.SeriesInstanceUID,
90
            sopInstanceUID: sopInstanceUID
91
          };
92
          var promise = dicomWebClient.retrieveInstanceMetadata(retrieveInstanceOptions).then(function (metadata) {
93
            var ImageType = metadata[0]['00080008']['Value'];
94
95
            if (ImageType[2] === 'VOLUME') {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if ImageType.2 === "VOLUME" is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
96
              return metadata[0];
97
            }
98
          });
99
          promises.push(promise);
100
        }
101
102
        return Promise.all(promises);
103
      }).then(
104
      /*#__PURE__*/
105
      function () {
106
        var _ref = _asyncToGenerator(
107
        /*#__PURE__*/
108
        regeneratorRuntime.mark(function _callee(metadata) {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
109
          var _ref2, api, microscopyViewer;
110
111
          return regeneratorRuntime.wrap(function _callee$(_context) {
0 ignored issues
show
Bug introduced by
The variable regeneratorRuntime seems to be never declared. If this is a global, consider adding a /** global: regeneratorRuntime */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
112
            while (1) {
113
              switch (_context.prev = _context.next) {
114
                case 0:
115
                  metadata = metadata.filter(function (m) {
116
                    return m;
117
                  });
118
                  _context.next = 3;
119
                  return __webpack_require__.e(/* import() | dicom-microscopy-viewer */ 10).then(__webpack_require__.t.bind(null, 1003, 7));
120
121
                case 3:
122
                  _ref2 = _context.sent;
123
                  api = _ref2.api;
0 ignored issues
show
Bug introduced by
The variable _ref2 is changed as part of the while loop for example by _context.sent on line 122. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
124
                  microscopyViewer = api.VLWholeSlideMicroscopyImageViewer;
0 ignored issues
show
Bug introduced by
The variable api is changed as part of the while loop for example by _ref2.api on line 123. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
125
                  _this2.viewer = new microscopyViewer({
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like microscopyViewer should be capitalized.
Loading history...
Bug introduced by
The variable microscopyViewer is changed as part of the while loop for example by api.VLWholeSlideMicroscopyImageViewer on line 124. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
126
                    client: dicomWebClient,
127
                    metadata: metadata,
128
                    retrieveRendered: false
129
                  });
130
131
                  _this2.viewer.render({
132
                    container: container
133
                  });
134
135
                case 8:
136
                case "end":
137
                  return _context.stop();
138
              }
139
            }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
140
          }, _callee);
141
        }));
142
143
        return function (_x) {
0 ignored issues
show
Unused Code introduced by
The parameter _x is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
144
          return _ref.apply(this, arguments);
145
        };
146
      }());
147
    }
148
  }, {
149
    key: "componentDidMount",
150
    value: function componentDidMount() {
151
      var displaySet = this.props.viewportData.displaySet;
152
      this.installOpenLayersRenderer(this.container.current, displaySet);
153
    }
154
  }, {
155
    key: "render",
156
    value: function render() {
157
      var style = {
158
        width: '100%',
159
        height: '100%'
160
      };
161
      return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
162
        className: 'DicomMicroscopyViewer',
163
        style: style
164
      }, react_resize_detector__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"] && react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_resize_detector__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"], {
165
        handleWidth: true,
166
        handleHeight: true,
167
        onResize: this.onWindowResize
168
      }), this.state.error ? react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("h2", null, JSON.stringify(this.state.error)) : react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
169
        style: style,
170
        ref: this.container
171
      }));
172
    }
173
  }]);
174
175
  return DicomMicroscopyViewport;
176
}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]);
177
178
/* harmony default export */ __webpack_exports__["default"] = (DicomMicroscopyViewport);
179
180
/***/ })
181
182
}]);